package com.youhui.weixin.config;

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by https://github.com/kuangcp on 17-11-19  下午7:47
 *
 * @author kuangcp
 */
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {

    @Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() {

        return (container -> {
            ErrorPage error401Page = new ErrorPage(HttpStatus.FORBIDDEN, "/nothavegood");
            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/nothavegood");
            ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/nothavegood");
            container.addErrorPages(error401Page, error404Page, error500Page);
        });
    }
}
